// should be included after game init

var _Font = require('core/font.js').font;
var _Atlas = require('core/font.js').atlas;
var _Text = require('drawable/text.js');
var _StyleText = require('drawable/styletext.js');
var _Style = _StyleText.Style;

var _program = require('global/programs.js');

function StyleConfig(config) {
    this.config = config;
}
StyleConfig.prototype.createText = function (text) {
    var conf = this.config;
    var atlas = new _Atlas(conf.width, conf.height, 1);
    var font = new _Font(atlas, BASEDIR + conf.font + '.ttf', conf.size);
    var ptext;
    if (conf.styles.length == 0) {
        ptext = new _Text(_program.textBlack.material(atlas), font);
    } else {
        ptext = new _StyleText(_program.textStyled.material(atlas), font, conf.styles);
    }
    if (text) {
        ptext.setText(text);
    }
    return ptext;
};
StyleConfig.prototype.enlarge = function (w, h) {
    var conf = {};
    for (var i in this.config) {
        conf[i] = this.config[i];
    }
    conf.width = w;
    conf.height = h;
    return new StyleConfig(conf);
};

var S = {
    cover: {
        complete: new StyleConfig({
            font: 'komika',
            size: 60,
            width: 512,
            height: 256,
            styles: [
                new _Style().outline_type(2).outline_thickness(2).color('9D3A09').offset(-1, -2),
                new _Style().outline_type(2).outline_thickness(2).color('EFE7CC'),
                new _Style().color('C7490D')
            ]
        })
    }
};

var BASEDIR = 'fonts/';

module.exports = S;
